layui.config({
	base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;

    form.on("submit(addArea)",function(data){
		 var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
    	 $.ajax({
			 type:'post',
			 url:'/admin/area/store',
             async:false,
			 data:{
			 	'_token':$('input[name=_token]').val(),
				 'name':$('input[name=areaName]').val()
			 },
			 dataType:'json',
			 success:function (data) {
			 	if(data.status == 1){
                    top.layer.close(index);
                    top.layer.msg("区域添加成功！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
				}else{
                    top.layer.close(index);
                    top.layer.msg("区域添加失败！");
				}
             }
		 })
        return false;
	})
})
